package com.yunyouyi.cpicture.domain.space.service.impl;

import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunyouyi.cpicture.domain.space.entity.SpaceUser;
import com.yunyouyi.cpicture.domain.space.service.SpaceUserDomainService;
import com.yunyouyi.cpicture.interfaces.dto.spaceuser.SpaceUserQueryDTO;
import org.springframework.stereotype.Service;


/**
* @author yunyouyi
* @description 针对表【space_user(空间用户关联)】的数据库操作Service实现
* @createDate 2025-04-27 15:27:01
*/
@Service
public class SpaceUserDomainServiceImpl implements SpaceUserDomainService {

    /**
     * 查询请求对象转换为Mybatis-Plus查询封装对象
     */
    @Override
    public QueryWrapper<SpaceUser> getQueryWrapper(SpaceUserQueryDTO spaceUserQueryDTO) {
        QueryWrapper<SpaceUser> queryWrapper = new QueryWrapper<>();
        if (spaceUserQueryDTO == null) {
            return queryWrapper;
        }
        // 从对象中取值
        Long id = spaceUserQueryDTO.getId();
        Long spaceId = spaceUserQueryDTO.getSpaceId();
        Long userId = spaceUserQueryDTO.getUserId();
        String spaceRole = spaceUserQueryDTO.getSpaceRole();
        queryWrapper.eq(ObjUtil.isNotEmpty(id), "id", id);
        queryWrapper.eq(ObjUtil.isNotEmpty(spaceId), "spaceId", spaceId);
        queryWrapper.eq(ObjUtil.isNotEmpty(userId), "userId", userId);
        queryWrapper.eq(ObjUtil.isNotEmpty(spaceRole), "spaceRole", spaceRole);
        return queryWrapper;
    }

}




